$(function() {
	var $body = $('body');
	if ( !$body.is('#smileys') ) return;

	var smileys = [];

	$('#center .smiley').each(function() {
		var $this = $(this);

		$this.attr({bot: $this.offset().top + $this.outerHeight()});
		smileys.push($this);

		$this
			.bind('mouseover', function() {
				$this.addClass('hover');
			})
			.bind('mouseout', function() {
				$this.removeClass('hover');
			});

		$('input', this)
			.bind('focus', function() {
				$this.addClass('focus');
			})
			.bind('blur', function() {
				$this.removeClass('focus');
			});
	});

	/*var arrange_smileys = function() {
		var $container = $('#center .content .smileys');
		var temp_smileys = [];
		for ( var i=0, $smiley=smileys[0]; ($smiley=smileys[i]); i++) {
			temp_smileys.push($smiley);

			if ( !smileys[i+1] || smileys[i+1].attr('bot') != $smiley.attr('bot') ) {
				//var $table = $('<table>');
				//var $tr = $('<tr>');
				var max_height = 0;
				for ( var i2=0, $s=temp_smileys[0]; ($s=temp_smileys[i2]); i2++) {
					max_height = ($s.outerHeight()>max_height)?$s.outerHeight():max_height;
					//var $td = $('<td>')
					//	.height($s.attr('bot') + 'px');
					//$td.append($s);
					//$tr.append($td);
				}
				for ( var i2=0, $s=temp_smileys[0]; ($s=temp_smileys[i2]); i2++) {
					max_height = ($s.outerHeight()>max_height)?$s.outerHeight():max_height;
					//var $td = $('<td>')
					//	.height($s.attr('bot') + 'px');
					//$td.append($s);
					//$tr.append($td);
				}
				temp_smileys = [];
				//$table.append($tr);
				//$container.append($table);
			}
		}
	};
	arrange_smileys();*/

	// EXTRAS
	$('.tags .more a').each(function() {
		var $this = $(this);
		var $container = $('.tags').has($this);
		$this.bind('click', function() {
			if ( $container.hasClass('show_more') ) {
				$container.removeClass('show_more');
			} else {
				$container.addClass('show_more');
			}
			return false;
		});
	});

	$('#show_extras a').bind('click', function() {
		$body.removeClass('hide_extras');
		$.cookie('hide_extras', null, { path: '/' });
		return false;
	});

	$('#hide_extras a').bind('click', function() {
		$body.addClass('hide_extras');
		$.cookie('hide_extras', 1, { expires: 30, path: '/' });
		return false;
	});
	// /EXTRAS

});